package com.offer;

import java.util.Stack;

/**
 * @Author: huangzhigao
 * @Date: 2023/3/4 16:22
 */
public class offer09 {
    private Stack<Integer> stack1 = new Stack<>();
    private Stack<Integer> stack2 = new Stack<>();

    public offer09() {

    }

    public void appendTail(int value) {
        stack1.add(value);
    }

    public int deleteHead() {
        if (!stack2.isEmpty()) {
            return stack2.pop();
        }

        while (!stack1.isEmpty()) {
            stack2.add(stack1.pop());
        }

        return stack2.isEmpty() ? -1 : stack2.pop();
    }
}
